//
// Created by Ylint on 2024/4/4.
//

#ifndef MPU6050TEST_KALMAN_H
#define MPU6050TEST_KALMAN_H

//extern float roll_kalman;

// 定义卡尔曼滤波器的状态
typedef struct {
    float x_hat; // 估计状态
    float P;     // 估计误差协方差
    float K;     // 卡尔曼增益
    float x_hat_prev; // 上一时刻估计状态
    float P_prev;     // 上一时刻估计误差协方差
} KalmanFilter;

// 定义卡尔曼滤波器的参数


extern float Kalman_Q;
extern float Kalman_R;
extern KalmanFilter kf;



void Kalman_Cal_Roll(float acc,float gyro);
void kalman_init(KalmanFilter *kf, float initial_estimate, float initial_error_covariance);
void kalman_update(KalmanFilter *kf, float z, float dt);


#endif //MPU6050TEST_KALMAN_H
